<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //定义对象字面量
      let obj = [{ name: 'foo', age: 19, 'nick name': 'bar' }]

      //取值
      console.log(obj.name) //等同于obj["name"]，点运算取值
      console.log(obj['nick name']) //因为key中含有空格这里只能如此访问，字符串索引取值
      //修改
      obj.age = 18
      //删除属性
      delete obj.name
      //枚举，将对象中key逐个取出(无序)
      for (var key in obj) {
        console.log(key + '->' + obj[key])
      }
    </script>
  </body>
</html>
